using UnityEngine;
using DG.Tweening;
using TMPro;
/// <summary>
/// 伤害飘字
/// </summary>
public class UIShowText : MonoBehaviour
{
    private TMP_Text text;
    public float jumpPower = 1f;//跳跃力度
    public float duration = 0.5f;//持续时间

    private void Awake()
    {
        text = GetComponent<TMP_Text>();
    }

    private void Start()
    {
        transform.DOScale(transform.localScale * 2, duration / 2).From(transform.localScale).SetLoops(2, LoopType.Yoyo);//先变大再变小
        text.DOFade(1f, duration / 2).From(0f).SetLoops(2, LoopType.Yoyo);//先渐显再渐隐
        //上跳效果
        transform.DOJump(transform.position, jumpPower, 1, duration).OnComplete(()=>{
            Destroy(gameObject);
        });
    }

    public void SetText(string str, Color color)
    {
        text.text = str;
        text.color = color;
    }
}
